

/*
plot example intraday windows
input data comes from proprietary sources

output:
- f4b_*.pdf: plots of windows around example auctions (govpx and cme)

*/


* plotting options
set scheme lean_uncluttered


********************************************************************************
********************************************************************************
* 2 examples: 
* August 11, 2011 (auction: 912810QS0; newly issued 30Y)
* December 9, 2010 (auction: 912810QL5; re-opened 30Y)
local datenums 20101209 20110811

* close time
local close_times `=hms(13,0,0)' `=hms(13,0,0)'

* release times from bloomberg
local release_times `=hms(13,1,46)' `=hms(13,1,38)'

* time tick options
local xwindow `=hms(0,15,0)'
local xstep `=hms(0,5,0)'

* titles

forvalues i=1/2 {
	* pull out info for given auction
	local datenum: word `i' of `datenums'
	local close_time: word `i' of `close_times'
	local release_time: word `i' of `release_times'
	
	* create window variables
	local xmin = `close_time' - `xwindow'
	local xmax = `close_time' + `xwindow'
	
	* xlabel only on bottom
	*if `i'==2 local x_axis_str xtitle("Time")
	*else local x_axis_str xtitle("")
	local x_axis_str xtitle("")
	
	n di `datenum'
	********
	* govpx
	n di "govpx"
	use ../data/input/govpx_`datenum'_clean.dta, clear

	* plot
	twoway line yld time, ///
		xscale(r(`xmin' `xmax')) xlabel(`xmin'(`xstep')`xmax') ///
		xline(`close_time' `release_time', ///
			lpattern(dash) lwidth(0.15) lcolor(black) ) ///
		`x_axis_str' ytitle("") title("") ///
		name(govpx_`datenum', replace) 
	
	********
	* cme
	n di "cme"
	use ../data/input/cme_`datenum'_clean.dta, clear

	* plot
	twoway line price time, ///
		xscale(r(`xmin' `xmax')) xlabel(`xmin'(`xstep')`xmax') ///
		xline(`close_time' `release_time', ///
			lpattern(dash) lwidth(0.15) lcolor(black) ) ///
		`x_axis_str' ytitle("") title("") ///
		name(cme_`datenum', replace) 
	
}

* combine with correct size and export
* govpx
* vertical
local fname f4b_govpx_shock_examples
graph combine govpx_20101209 govpx_20110811, ///
	rows(2) imargin(tiny) xsize(8) ysize(6) name(`fname', replace)
* add titles
gr_edit .plotregion1.graph1.title.text.Arrpush "Panel A: December 9, 2010"
gr_edit .plotregion1.graph2.title.text.Arrpush "Panel B: August 11, 2011"
graph export ../figs/`fname'.pdf, replace
graph export ../figs/`fname'.eps, replace


* cme
local fname f4b_cme_shock_examples
graph combine cme_20101209 cme_20110811, ///
	rows(2) xsize(8) ysize(6) imargin(tiny)
* add titles
gr_edit .plotregion1.graph1.title.text.Arrpush "Panel A: December 9, 2010"
gr_edit .plotregion1.graph2.title.text.Arrpush "Panel B: August 11, 2011"
graph export ../figs/`fname'.pdf, replace
graph export ../figs/`fname'.eps, replace

* also save separately
forvalues i=1/2 {
	local datenum: word `i' of `datenums'
	* govpx
	local fname f4b_govpx_shock_examples_`datenum'
	graph display govpx_`datenum', xsize(8) ysize(5)
	graph export ../figs/`fname'.pdf, replace
	graph export ../figs/`fname'.eps, replace
	
	* cme
	local fname f4b_cme_shock_examples_`datenum'
	graph display cme_`datenum', xsize(8) ysize(5)
	graph export ../figs/`fname'.pdf, replace
	graph export ../figs/`fname'.eps, replace
}



